package wyn.action;

import org.apache.log4j.Logger;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import wyn.entity.SysName;
import wyn.service.UserServiceI;

import java.util.UUID;

/**
 * Created by 王亚楠 on 2016/2/21.
 */
@ParentPackage("basePackage")
@Namespace("/")
@Action("userAction")
public class UserAction {

    private UserServiceI manager;

    public UserServiceI getManager() {
        return manager;
    }

    @Autowired
    public void setManager(UserServiceI manager) {
        this.manager = manager;
    }

    public static final Logger logger = Logger.getLogger(UserAction.class);

    public void TestUserAction(){
        logger.info("测试Struts2成功");
    }

    public void addUser(){
        SysName user = new SysName();
        user.setGuid(UUID.randomUUID().toString());
        user.setName("唐颖");
        user.setAge(23);
        user.setPower(100.0);
        manager.save(user);
    }

}
